# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.AnalyticsData.V1beta.Model.CohortSpec do
  @moduledoc """
  The specification of cohorts for a cohort report. Cohort reports create a time series of user retention for the cohort. For example, you could select the cohort of users that were acquired in the first week of September and follow that cohort for the next six weeks. Selecting the users acquired in the first week of September cohort is specified in the `cohort` object. Following that cohort for the next six weeks is specified in the `cohortsRange` object. For examples, see [Cohort Report Examples](https://developers.google.com/analytics/devguides/reporting/data/v1/advanced#cohort_report_examples). The report response could show a weekly time series where say your app has retained 60% of this cohort after three weeks and 25% of this cohort after six weeks. These two percentages can be calculated by the metric `cohortActiveUsers/cohortTotalUsers` and will be separate rows in the report.

  ## Attributes

  *   `cohortReportSettings` (*type:* `GoogleApi.AnalyticsData.V1beta.Model.CohortReportSettings.t`, *default:* `nil`) - Optional settings for a cohort report.
  *   `cohorts` (*type:* `list(GoogleApi.AnalyticsData.V1beta.Model.Cohort.t)`, *default:* `nil`) - Defines the selection criteria to group users into cohorts. Most cohort reports define only a single cohort. If multiple cohorts are specified, each cohort can be recognized in the report by their name.
  *   `cohortsRange` (*type:* `GoogleApi.AnalyticsData.V1beta.Model.CohortsRange.t`, *default:* `nil`) - Cohort reports follow cohorts over an extended reporting date range. This range specifies an offset duration to follow the cohorts over.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :cohortReportSettings =>
            GoogleApi.AnalyticsData.V1beta.Model.CohortReportSettings.t() | nil,
          :cohorts => list(GoogleApi.AnalyticsData.V1beta.Model.Cohort.t()) | nil,
          :cohortsRange => GoogleApi.AnalyticsData.V1beta.Model.CohortsRange.t() | nil
        }

  field(:cohortReportSettings, as: GoogleApi.AnalyticsData.V1beta.Model.CohortReportSettings)
  field(:cohorts, as: GoogleApi.AnalyticsData.V1beta.Model.Cohort, type: :list)
  field(:cohortsRange, as: GoogleApi.AnalyticsData.V1beta.Model.CohortsRange)
end

defimpl Poison.Decoder, for: GoogleApi.AnalyticsData.V1beta.Model.CohortSpec do
  def decode(value, options) do
    GoogleApi.AnalyticsData.V1beta.Model.CohortSpec.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.AnalyticsData.V1beta.Model.CohortSpec do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
